import Taro, { Component } from '@tarojs/taro'
import { View, Button, SwiperItem, Text } from '@tarojs/components'
import styles from './index.module.scss'
import classNames from 'classnames'
import {copyText} from "@/utils/utils";
// import { getBrand } from '@/utils/storage'
import {FyPopup} from "@/components/index";


interface IProps {
  show: boolean
  onChange: any
  onBack: any
}
export default class Index extends Component<IProps, {}> {
  props: any
  state: any

  constructor(props) {
    super(...arguments)
    this.state = {
      visible: props.show
    }
  }

  componentWillReceiveProps({ show }) {
    this.setState({
      visible: show
    })
  }

  changeShow() {
    const { onChange } = this.props
    this.setState({
      visible: false
    })
    if (onChange) {
      onChange(false)
    }
  }
  onBackCallback() {
    const { onBack } = this.props
    this.setState({
      visible: false
    })
    if (onBack) {
      onBack(false)
    }
    Taro.navigateBack()
  }

  render() {
    const { visible } = this.state
    // const { onBackCallback } = this.props


    return (visible ? <View>
      <FyPopup visible={visible} type='overlay' position='fade' className={styles.overlay}/>
      {/*<FyPopup visible={visible} type='overlay' position='fade' className={styles.popup}>*/}
      <View className={classNames(`${styles.popup} f-g-5 f-d-c`, visible && styles.popupInUp)}>
        <View className={styles.content}>
          <View className={styles.title}>温馨提示</View>
          <View>您的订单还未支付</View>
          <View>为避免金币过期，请尽快支付</View>
          <View className={styles.action}>
            {/*<View className={styles.actionItem} onClick={() => Taro.navigateBack()}>暂时放弃</View>*/}
            <View className={styles.actionItem} onClick={this.onBackCallback.bind(this)}>暂时放弃</View>
            <View className={styles.actionItem} onClick={this.changeShow.bind(this)}>确定</View>
          </View>
        </View>
      </View>
    </View> : null)
  }

  // render() {
  //   // const { info } = this.props
  //   const { visible, url } = this.state
  //   // console.log(url)
  //   // console.log('info', info)
  //
  //   return (visible ? <View className={styles.shareModal} onClick={this.changeShow.bind(this)}>
  //     <View className={styles.content}>
  //       <View className={classNames('fy-icon-font', styles.closeIcon)} onClick={this.changeShow.bind(this)}>&#xe7dc;</View>
  //       {/*<View>分享给好友，送你500金币</View>*/}
  //       <h3 className='m-t-30'>分享口令已复制</h3>
  //       <h3 className='m-b-30'>快去微信粘贴给好友吧</h3>
  //
  //       <Button type="primary" onClick={() => copyText(url)} >去微信粘贴</Button>
  //     </View>
  //   </View> : null)
  // }
}
